package com.jiangnan.api.client

import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext

object ApiClient {

    private const val BASE_URL = "https://example.com/"

    private val retrofit: Retrofit by lazy {
        Retrofit.Builder()
            .baseUrl(BASE_URL)
            .addConverterFactory(GsonConverterFactory.create())  // JSON 转换器
            .build()
    }
    // 可以选择增加协程调度器控制 API 请求
    suspend fun <T> apiCall(call: suspend () -> T): T {
        return withContext(Dispatchers.IO) {
            call()
        }
    }



}